//
//  JLXXViewController.m
//  JLXXFlashView
//
//  Created by cnsuer on 07/03/2017.
//  Copyright (c) 2017 cnsuer. All rights reserved.
//

#import "JLXXViewController.h"
#import "FlashViewNew.h"

@interface JLXXViewController ()

@property (nonatomic, strong) FlashViewNew *flashViewNew;

@property (nonatomic , copy) NSString *currAnimName;

@end

@implementation JLXXViewController

-(FlashViewNew *)flashViewNew{
    if (!_flashViewNew) {
        _flashViewNew = [[FlashViewNew alloc] init];
        _flashViewNew.userInteractionEnabled = NO;
        [self.view addSubview:_flashViewNew];
    }
    return _flashViewNew;
}


- (IBAction)first:(id)sender {
    self.currAnimName = @"bieshu";
    [self playAnima];

}

- (IBAction)second:(id)sender {
    self.currAnimName = @"laba";
    [self playAnima];
}

- (IBAction)third:(id)sender {
    self.currAnimName = @"mutiFlowerDrop";
    [self playAnima];
}

- (IBAction)forth:(id)sender {
    self.currAnimName = @"mutiFlowerRandom";
    [self playAnima];
}


-(void)playAnima{
    
    [self.flashViewNew reload:self.currAnimName];
    
    [self.flashViewNew play:self.flashViewNew.animNames[0] loopTimes:1];
    
    self.flashViewNew.onEventBlock = ^(FlashViewEvent evt, id data){
        if (evt == FlashViewEventStop) {
            //            weakCtl.nextIndex++;
            //            if (weakCtl.nextIndex >= flashView.animNames.count) {
            //                weakCtl.nextIndex = 0;
            //            }
            //            [weakFlashView play:weakFlashView.animNames[weakCtl.nextIndex] loopTimes:FlashViewLoopTimeOnce];
        }
    };

}
@end
